import random

def generate_test_case():
    # 生成候选数组的长度，范围在1到30之间
    length = random.randint(1, 30)
    # 生成候选数组，元素范围在2到40之间，且无重复
    candidates = random.sample(range(2, 41), length)
    # 生成目标值，范围在1到40之间
    target = random.randint(1, 40)
    return candidates, target

def save_test_case(test_case, filename):
    with open(filename, 'w') as f:
        f.write(f"candidates = {test_case[0]}\n")
        f.write(f"target = {test_case[1]}\n")

if __name__ == "__main__":
    # 生成5个测试用例
    for i in range(5):
        test_case = generate_test_case()
        save_test_case(test_case, f"test_case_{i+1}.txt")
        print(f"Generated test case {i+1}: candidates={test_case[0]}, target={test_case[1]}")